//package com.cainiao.stock.config;
//
//import com.cainiao.stock.cache.Cache;
//import com.cainiao.stock.cache.impl.RedisCache;
//import org.springframework.context.annotation.Bean;
//import org.springframework.context.annotation.Configuration;
//import org.springframework.data.redis.core.StringRedisTemplate;
//
///**
// * @author a
// */
//@Configuration
//public class RedisConfiguration {
//
//    @Bean
//    public Cache cache(StringRedisTemplate redisTemplate){
//        return new RedisCache(redisTemplate);
//    }
//}
package com.cainiao.stock.config;


import com.cainiao.stock.cache.Cache;
import com.cainiao.stock.cache.impl.RedisCache;
import com.cainiao.stock.properties.RateLimiterProperties;
import com.google.common.util.concurrent.RateLimiter;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.data.redis.core.StringRedisTemplate;

@Configuration
@SuppressWarnings("all")
public class RateLimiterConfiguration {

    @Bean
    public RateLimiter rateLimiter(RateLimiterProperties rateLimiterProperties){
        return RateLimiter. create(rateLimiterProperties.getConcurrentNum());
    }
}
